<!DOCTYPE html>
<html lang="zh">
<head>
    <th:block th:include="include :: header('文件上传')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>文件上传控件 <small>https://github.com/kartik-v/bootstrap-fileinput</small></h5>
                </div>
                <div class="ibox-content">
                    <div class="form-group">
                        <label class="font-noraml">单文件上传</label>
                        <div class="file-loading">
                            <input id="singleFile" name="file" type="file">
                        </div>
                    </div>

                    <hr>
                    <form id="caipai">
                        <div class="form-group">
                            <label>文件id：</label>
                            <div>
                                <input name="fileId" type="text"  class="form-control" placeholder="请输入">
                            </div>
                        </div>
                        <div class="form-group">
                            <label>预测号码分号隔开|,4|5|6：</label>
                            <div>
                                <input name="numbers" type="text"  class="form-control" placeholder="请输入">
                            </div>
                        </div>
                        <div class="form-group">
                            <label>预测出现次数：</label>
                            <div>
                                <input name="count" type="text"  class="form-control" placeholder="请输入">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="font-noraml">
                                <button id="btnSubmit"  onclick="computerCaiPiao()" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    function computerCaiPiao(){
        var numbers = $.common.trim($("input[name='numbers']").val());
        var count = $.common.trim($("input[name='count']").val());
        var fileId = $.common.trim($("input[name='fileId']").val());
        $.ajax({
            type: "post",
            url: ctx + "computerCaiPiao",
            data: {

                "numbers": numbers,
                "count": count,
                "fileId": fileId,
            },
            beforeSend: function () {
                $.modal.loading($("#btnSubmit").data("loading"));
            },
            success: function(r) {
                $.modal.closeLoading();
                alert(r);
            }
        });

    };

    $(document).ready(function () {
        function login() {
            var fileId = $.common.trim($("input[name='username']").val());
            var selectedNumbers = $.common.trim($("input[name='password']").val());
            var numberOfMatches = $$("input[name='rememberme']").is(':checked');
            $.ajax({
                type: "post",
                url: ctx + "login",
                data: {
                    "username": username,
                    "password": password,
                    "validateCode": validateCode,
                    "rememberMe": rememberMe
                },
                beforeSend: function () {
                    $.modal.loading($("#btnSubmit").data("loading"));
                },
                success: function(r) {
                    if (r.code == web_status.SUCCESS) {
                        location.href = ctx + 'index';
                    } else {
                        $('.imgcode').click();
                        $(".code").val("");
                        $.modal.msg(r.msg);
                    }
                    $.modal.closeLoading();
                }
            });
        }



        // 单图上传
        $("#singleFile").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            var rsp = data.response;
            log.info("return url：" + rsp.url)
            log.info("reutrn fileName：" + rsp.fileName)
            log.info("reutrn newFileName：" + rsp.newFileName)
            log.info("return originalFilename：" + rsp.originalFilename)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })


    });
</script>
</body>
</html>
